{include file="../template/header.html" /}

<div class="my-3 my-md-5">
    <div class="container">
        <div class="row">
            <div class="col-lg-12 mx-auto">
                <form class="card" method="POST" enctype="multipart/form-data">
                    <div class="card-body">
                        <h3 class="card-title">文章发布</h3>
                        <div class="row">
                            <div class="col-md-8">
                                <div class="form-group">
                                    <label class="form-label">标题</label>
                                    <input type="text" class="form-control" name="title" required>
                                </div>
                            </div>
                            <div class="col-md-4">
                                <div class="form-group">
                                    <label class="form-label">封面图</label>
                                    <input type="file" accept="image/gif,image/jpeg,image/png" class="form-control"
                                        name="cover_img" required>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <div class="form-group">
                                        <label class="form-label">摘要</label>
                                        <textarea class="form-control" name="desp"></textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-12">
                                <div class="form-group">
                                    <label class="form-label">正文内容</label>
                                    <div id="editor"></div>
                                    <textarea class="form-control" id="content" name="content"
                                        style="display: none"></textarea>
                                </div>
                            </div>
                        </div>

                        <div class="card-footer text-right">
                            <button type="submit" class="btn btn-primary" name="addArticle">提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    require(['__JS__/wangEditor.min.js'], function (E) {
    var editor = new E('#editor')
    editor.customConfig.onchange = function (html) {
            // 监控变化，同步更新到 textarea
            $("#content").val(html)
        }
    editor.customConfig.menus = [
    'head',  // 标题
    'bold',  // 粗体
    'fontSize',  // 字号
    'italic',  // 斜体
    'underline',  // 下划线
    'foreColor',  // 文字颜色
    'justify',  // 对齐方式
    'image',  // 插入图片
    ]
    editor.customConfig.uploadImgServer = '/Customer/CaseImgUpload'
    editor.customConfig.uploadImgMaxLength = 1
    editor.customConfig.uploadFileName = 'caseImg'
    editor.create()
    })
</script>
{include file="../template/footer.html" /}